package com.chen.pfm.entity;

import com.chen.pfm.utils.DateUtils;
import ohos.data.orm.OrmObject;
import ohos.data.orm.annotation.Column;
import ohos.data.orm.annotation.Entity;
import ohos.data.orm.annotation.PrimaryKey;
import ohos.data.rdb.ValuesBucket;

import java.util.Date;
@Entity(tableName = "user")
public class User extends OrmObject {
    @Column(name = "uid", index = true)
    @PrimaryKey(autoGenerate = true)
    private Integer uid;//主键
    @Column(name = "userid", index = true)
    private String userid;//用户账号
    private String password;//密码
    private String username;//ningcheng
    private String gender;
    private String birthday;
    private String grade;
    private String createtime;


    public User() {
    }



    public User(Integer uid, String userid, String password, String username, String gender, String birthday, String grade, String createtime) {
        this.uid = uid;
        this.userid = userid;
        this.password = password;
        this.username = username;
        this.gender = gender;
        this.birthday = birthday;
        this.grade = grade;
        this.createtime = createtime;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCreatetime() {
        return createtime;
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }


    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", userid='" + userid + '\'' +
                ", password='" + password + '\'' +
                ", username='" + username + '\'' +
                ", gender='" + gender + '\'' +
                ", birthday='" + birthday + '\'' +
                ", grade='" + grade + '\'' +
                ", createtime='" + createtime + '\'' +
                '}';
    }

    public User getObjectfromValues(ValuesBucket valuesBucket) {

        this.uid = valuesBucket.getInteger("uid");
        this.userid = valuesBucket.getString("userid");
        this.password = valuesBucket.getString("password");
        this.username = valuesBucket.getString("username");
        this.gender = valuesBucket.getString("gender");
        this.grade = valuesBucket.getString("grade");
        this.birthday = valuesBucket.getString("birthday");
        this.createtime = valuesBucket.getString("createtime");
        return this;
    }

    public ValuesBucket getValuesBucketfromObject() {
        ValuesBucket valuesBucket = new ValuesBucket();
        valuesBucket.putInteger("uid", uid);
        valuesBucket.putString("userid", userid);
        valuesBucket.putString("password", password);
        valuesBucket.putString("username", username);
        valuesBucket.putString("gender", gender);
        valuesBucket.putString("grade", grade);
        valuesBucket.putString("birthday", birthday);
        valuesBucket.putString("createtime", createtime);
        return valuesBucket;
    }
}
